*******高分************/谁能帮我写个makefile

lynnxn 2003-08-30 04:29:38
是这样的,我做的程序需要联接两个库,一个是ltilib,现在想用wx-GTK-2.4.1作个界面.我用ltilib的时候是用他给的makefile.
#----------------------------------------------------------------
# project ....: LTI Digital Image/Signal Processing Library
# file .......: Template Makefile for Examples
# authors ....: Pablo Alvarado, Jochen Wickel
# organization: LTI, RWTH Aachen
# creation ...: 09.02.2003
# revisions ..: $Id: Makefile.in,v 1.5 2003/06/02 06:34:16 alvarado Exp $
#----------------------------------------------------------------

#Base Directory
LTIBASE:=../..
LTICMD:=$(LTIBASE)/linux/lti-local-config

#Example name
PACKAGE:=$(shell basename $$PWD)

# If you want to generate a debug version, uncomment the next line
BUILDRELEASE=yes

# Compiler to be used
CC:=g++

# For new versions of gcc, <limits> already exists, but in older
# versions a replacement is needed
CC_MAJOR:=$(shell echo `$(CC) --version | sed -e 's/\..*//;'`)

ifeq "$(CC_MAJOR)" "2"
VPATHADDON=:../../linux/g++
CPUARCH:=-march=i686 -mcpu=i686
else
VPATHADDON=
CPUARCH:=-march=pentium4 -mcpu=pentium4
endif

# Directories with source file code (.h and .cpp)
VPATH:=$(VPATHADDON)

# Destination directories for the debug and release versions of the code

OBJDIR = ./

# Extra include directories and library directories for hardware specific stuff

EXTRAINCLUDEPATH =
EXTRALIBPATH =
EXTRALIBS =

#EXTRAINCLUDEPATH = -I/usr/src/menable/include
#EXTRALIBPATH = -L/usr/src/menable/lib
#EXTRALIBS = -lpulnixchanneltmc6700 -lmenable


# PROFILE = -p
PROFILE=

# compiler flags
CXXINCLUDE:=$(EXTRAINCLUDEPATH) $(patsubst %,-I%,$(subst :, ,$(VPATH)))

LINKDIR:=-L$(LTIBASE)/lib
CPPFILES=$(wildcard ./*.cpp)
OBJFILES=$(patsubst %.cpp,$(OBJDIR)%.o,$(notdir $(CPPFILES)))

# set the compiler/linker flags depending on the debug/release flag
ifeq "$(BUILDRELEASE)" "yes"
LTICXXFLAGS:=$(shell $(LTICMD) --cxxflags)
CXXFLAGSREL:=-c -O3 $(CPUARCH) -Wall -ansi $(LTICXXFLAGS) $(CXXINCLUDE)
GCC:=$(CC) $(CXXFLAGSREL) $(PROFILE)
LIBS:=$(shell $(LTICMD) --libs) $(EXTRALIBS)
else
LTICXXFLAGS:=$(shell $(LTICMD) --cxxflags debug)
CXXFLAGSDEB:=-c -g $(CPUARCH) -Wall -ansi $(LTICXXFLAGS) $(CXXINCLUDE)
GCC:=$(CC) $(CXXFLAGSDEB) $(PROFILE)
LIBS:=$(shell $(LTICMD) --libs debug) $(EXTRALIBS)
endif

LNALL = $(CC) $(PROFILE)

# implicit rules
$(OBJDIR)%.o : %.cpp
@echo "Compiling $<..."
@$(GCC) $< -o $@

all: $(PACKAGE)

# example
$(PACKAGE): $(OBJFILES)
@echo "Linking $(PACKAGE)..."
@$(LNALL) -o $(PACKAGE) $(OBJFILES) $(LIBS)

clean:
@echo "Removing *.o files..."
@rm -f *.o
@echo "Ready."

clean-all:
@echo "Removing files..."
@echo " removing obj, core and binary files..."
@rm -f ./core* $(PACKAGE) $(OBJDIR)*.o
@echo " removing emacs backup files..."
@find $$PWD \( -name '*\~' -or -name '\#*' \) -exec rm -f {} \;
@echo " removing other automatic created backup files..."
@find $$PWD \( -name '\.\#*' -or -name '\#*' \) -exec rm -f {} \;
@rm -fv nohup.out
@echo "Ready."

debug:
@echo "Package: $(PACKAGE)"

# you can change this target, if you don't want the general make file
# to replace this makefile
Makefile: ../template/Makefile
@echo "Getting template/Makefile..."
@cp -v ../template/Makefile .
我要是想多连一个wxGtk库的话,怎么改讷.我看不大懂这个makefile.
编译另一个库的makefile
#
# File: Makefile for samples
# Author: Robert Roebling
# Created: 1999
# Updated:
# Copyright: (c) 1998 Robert Roebling
#
# This makefile requires a Unix version of wxWindows
# to be installed on your system. This is most often
# done typing "make install" when using the complete
# sources of wxWindows or by installing the two
# RPM packages wxGTK.XXX.rpm and wxGTK-devel.XXX.rpm
# under Linux.
#

CXX = $(shell wx-config --cxx)

PROGRAM = pngdemo

OBJECTS = $(PROGRAM).o

# implementation

.SUFFIXES: .o .cpp

.cpp.o :
$(CXX) -c `wx-config --cxxflags` -o $@ $<

all: $(PROGRAM)

$(PROGRAM): $(OBJECTS)
$(CXX) -o $(PROGRAM) $(OBJECTS) `wx-config --libs`

clean:
rm -f *.o $(PROGRAM)
一大堆,完全看不懂.
请教哪位高手帮我写一个makefile能连这两个库.
...全文
47 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
fierygnu 2003-09-01
  • 打赏
  • 举报
回复
拜托一次说清楚好不好?环境变量设在shell里,跟Makefile有什么关系?如果在Makefile里要用,就用${NAME}来引用。
lynnxn 2003-09-01
  • 打赏
  • 举报
回复
还是不行,他有一些环境变量
fierygnu 2003-08-31
  • 打赏
  • 举报
回复
都加在LIBS里。
mynetpc 2003-08-31
  • 打赏
  • 举报
回复
http://community.freebsdchina.org/document.php?topic=4113&forum=40
这个网页教你自动产生makefile
daehappy 2003-08-30
  • 打赏
  • 举报
回复
$(PROGNAME) : $(OBJS)
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)


注意第二行前面不是空格而是一个tab!!
fierygnu 2003-08-30
  • 打赏
  • 举报
回复
如果一定要用Makefile:
CC= gcc
DEFS=
PROGNAME= urapp
INCLUDES= -I.
LIBS= -llib1 -llib2

# replace -O with -g in order to debug

DEFINES= $(INCLUDES) $(DEFS)
CFLAGS= -O $(DEFINES)

SRCS = urfile.c

OBJS = urfile.o

.c.o:
rm -f $@
$(CC) $(CFLAGS) -c $*.c

all: $(PROGNAME)

$(PROGNAME) : $(OBJS)
$(CC) $(CFLAGS) -o $(PROGNAME) $(OBJS) $(LIBS)
fierygnu 2003-08-30
  • 打赏
  • 举报
回复
你这么简单的要求不需要makefile也行:
gcc -o urapp urapp.c -llib1 -llib2
lynnxn 2003-08-30
  • 打赏
  • 举报
回复
关键的问题是这两个库都不是独立的,编译的时候都倚赖其他好几个库.这样写根本就不行

23,110

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧