当前位置: 技术问答>linux和unix
那位老大帮忙 linux下问题
来源: 互联网 发布时间:2016-08-19
本文导语: 本帖最后由 yunyun050924 于 2010-04-17 14:17:28 编辑 学习linux,automake不能生成Makefile.in,导致不能make,求解方法。或者帮些一个脚本,可以自动检测目录下的源文件,并编译运行。 | 给你个 M...
|
给你个 Makefie, 可以自己搜索并编译该目录下的所有文件。
binexec := binexec
subdirs := . src
sources := $(foreach subdir, $(subdirs), $(wildcard $(subdir)/*.c))
headers := $(foreach subdir, $(subdirs), $(wildcard $(subdir)/*.h))
objects := $(sources:.c=.o)
deps := $(sources:.c=.d)
INCLUDE := $(addprefix -I, $(subdirs))
CFLAGS := -g
RM := rm -f
TAR := tar
GZIP := gzip
me := Makefile
all: $(binexec)
binexec:$(objects)
$(CC) -o $@ $(objects) $(LDFLAGS) $(LDLIBS)
dist:
pkg=`pwd`; tar cvf - $(me) $(sources) $(headers)
| $(GZIP) -c > `basename $${pkg}`.tar.gz
clean:
$(RM) $(objects)
$(RM) $(deps)
$(RM) $(binexec)
-include $(deps)
binexec := binexec
subdirs := . src
sources := $(foreach subdir, $(subdirs), $(wildcard $(subdir)/*.c))
headers := $(foreach subdir, $(subdirs), $(wildcard $(subdir)/*.h))
objects := $(sources:.c=.o)
deps := $(sources:.c=.d)
INCLUDE := $(addprefix -I, $(subdirs))
CFLAGS := -g
RM := rm -f
TAR := tar
GZIP := gzip
me := Makefile
all: $(binexec)
binexec:$(objects)
$(CC) -o $@ $(objects) $(LDFLAGS) $(LDLIBS)
dist:
pkg=`pwd`; tar cvf - $(me) $(sources) $(headers)
| $(GZIP) -c > `basename $${pkg}`.tar.gz
clean:
$(RM) $(objects)
$(RM) $(deps)
$(RM) $(binexec)
-include $(deps)