root / tags / leocad-0-74 / Makefile

Revision 403, 3.5 kB (checked in by leo, 4 years ago)

Updated LeoCAD to use GTK+ 2.0

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1### ALL CONFIGURATION SHOULD BE IN CONFIG.MK, NOT HERE
2include config.mk
3
4### Module directories
5MODULES := $(OSDIR) common
6
7### look for include files in
8###   each of the modules
9CPPFLAGS += $(patsubst %,-I%,$(MODULES)) $(OS)
10CPPFLAGS += -g
11
12### extra libraries if required
13LIBS :=
14
15### each module will add to this
16SRC :=
17
18BIN := bin/leocad
19
20-include $(OSDIR)/config.mk
21
22### include the description for
23###   each module
24include $(patsubst %,%/module.mk,$(MODULES))
25
26### determine the object files
27OBJ := \
28  $(patsubst %.c,%.o,$(filter %.c,$(SRC))) \
29  $(patsubst %.cpp,%.o,$(filter %.cpp,$(SRC)))
30
31### link the program
32.PHONY: all static
33
34all: $(BIN)
35
36static: bin/leocad.static
37
38bin/leocad: $(OBJ) bin
39    $(CXX) -o $@ $(OBJ) $(LIBS)
40
41bin/leocad.static: $(OBJ) bin
42    $(CXX) -static -o $@ $(OBJ) $(LIBS)
43
44bin:
45    mkdir bin
46
47### include the C/C++ include
48###   dependencies
49ifeq ($(findstring $(MAKECMDGOALS), help config-help config clean veryclean spotless), )
50-include $(OBJ:.o=.d)
51endif
52
53### calculate C/C++ include
54###   dependencies
55%.d: %.c
56    @[ -s $(OSDIR)/config.h ] || $(MAKE) config
57    @$(CC) -MM -MT '$(patsubst %.d,%.o, $@)' $(CFLAGS) $(CPPFLAGS) -w $< > $@
58    @[ -s $@ ] || rm -f $@
59
60%.d: %.cpp
61    @[ -s $(OSDIR)/config.h ] || $(MAKE) config
62    @$(CXX) -MM -MT '$(patsubst %.d,%.o, $@)' $(CXXFLAGS) $(CPPFLAGS) -w $< > $@
63    @[ -s $@ ] || rm -f $@
64
65### Various cleaning functions
66.PHONY: clean veryclean spotless all
67
68clean:
69    find $(MODULES) -name \*.o | xargs rm -f
70
71veryclean: clean
72    find $(MODULES) -name \*.d | xargs rm -f
73    rm -rf bin
74
75spotless: veryclean
76    rm -rf arch $(OSDIR)/config.mk $(OSDIR)/config.h
77
78
79### dependency stuff is done automatically, so these do nothing.
80.PHONY: dep depend
81
82
83### Help function
84.PHONY: help
85
86help:
87    @echo   'Possible Targets are:'
88    @echo   '       help (this is it)'
89    @echo   '       all'
90    @echo   '       install'
91    @echo   '       binary'
92    @echo   '       source'
93    @echo   '       (binary and source can be called as'
94    @echo   '        a -zip or -tgz variants)'
95    @echo   '       clean'
96    @echo   '       veryclean'
97    @echo   '       spotless'
98    @echo
99
100###  Rules to make various packaging
101.PHONY: binary binary-tgz source-zip source-tgz source install
102
103arch:
104    mkdir arch
105
106install: $(BIN)
107    install -d $(DESTDIR)$(PREFIX)/bin
108    install -d $(DESTDIR)$(PREFIX)/share/man/man1
109    install -c -m 0755 $(BIN) $(DESTDIR)$(PREFIX)/bin/
110    install -c -m 0644 docs/leocad.1 $(DESTDIR)$(PREFIX)/share/man/man1/
111
112binary: binary-zip binary-tgz
113
114binary-zip: arch/leocad-$(VERSION)-linux.zip
115
116binary-tgz: arch/leocad-$(VERSION)-linux.tgz
117
118source: source-tgz source-zip
119
120source-tgz: arch/leocad-$(VERSION)-src.tgz
121
122source-zip: arch/leocad-$(VERSION)-src.zip
123
124### Create a directory with the files needed for a binary package
125package-dir: arch all
126    mkdir leocad-$(VERSION)
127    cp bin/leocad leocad-$(VERSION)
128    cp CREDITS.txt leocad-$(VERSION)/CREDITS
129    cp README.txt leocad-$(VERSION)/README
130    cp docs/INSTALL.txt leocad-$(VERSION)/INSTALL
131    cp docs/LINUX.txt leocad-$(VERSION)/LINUX
132    cp docs/leocad.1 leocad-$(VERSION)
133
134arch/leocad-$(VERSION)-linux.zip: package-dir
135    rm -f $@
136    zip -r $@ leocad-$(VERSION)
137    rm -rf leocad-$(VERSION)
138
139arch/leocad-$(VERSION)-linux.tgz: package-dir
140    rm -f $@
141    tar -cvzf $@ leocad-$(VERSION)
142    rm -rf leocad-$(VERSION)
143
144arch/leocad-$(VERSION)-src.tgz: arch veryclean
145    rm -f $@
146    ( cd .. ; tar --exclude=leocad/arch/\* --exclude=CVS \
147    -cvzf leocad/$@ leocad )
148
149arch/leocad-$(VERSION)-src.zip: arch veryclean
150    rm -f $@
151    ( cd .. ; zip -r leocad/$@ leocad -x '*/arch/*' -x '*/CVS/*' -x '*~' -x '*/core' -x '*/.#*')
Note: See TracBrowser for help on using the browser.