1 # Makefile for building the idl tool. 2 # 3 # Copyright (C) 2019, 2020, 2021, 2022 Paul Boddie <paul@boddie.org.uk> 4 # 5 # This program is free software; you can redistribute it and/or 6 # modify it under the terms of the GNU General Public License as 7 # published by the Free Software Foundation; either version 2 of 8 # the License, or (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 # Boston, MA 02110-1301, USA 19 20 # Original sources, headers and final program. 21 22 SOURCES = \ 23 main.c client.c common.c config.c declaration.c dispatch.c imports.c \ 24 includes.c interface.c message.c program.c server.c \ 25 structure.c summary.c 26 27 HEADERS = \ 28 client.h common.h config.h declaration.h dispatch.h imports.h \ 29 includes.h interface.h message.h parser.h program.h server.h \ 30 structure.h summary.h \ 31 templates.h types.h 32 33 PROGRAM = idl 34 35 # Generated files from flex and bison. 36 37 SCANNER = lex.yy.c 38 PARSER = y.tab.c 39 HEADER = y.tab.h 40 GENERATED = $(SCANNER) $(PARSER) 41 42 # Version-related files. 43 44 VERSION = version.h 45 46 # Computed values. 47 48 ALL_SOURCES = $(SOURCES) $(GENERATED) 49 OBJECTS = $(patsubst %.c,%.o,$(SOURCES)) 50 51 # Flags and options. 52 53 CFLAGS = -D_GNU_SOURCE 54 #DEBUG = -DYYDEBUG=1 55 56 # Rules. 57 58 .PHONY: all clean version 59 60 all: $(PROGRAM) 61 62 $(VERSION): version 63 echo "#define VERSION_INFORMATION \"$(shell hg identify -i)\"" > $(VERSION) 64 65 version: 66 67 clean: 68 $(RM) $(PROGRAM) $(GENERATED) $(HEADER) $(OBJECTS) 69 70 $(PROGRAM): $(GENERATED) $(OBJECTS) 71 $(CC) $(CFLAGS) -o $@ $(GENERATED) $(OBJECTS) -ll 72 73 $(SCANNER): idl.lex 74 flex $< 75 76 $(PARSER): idl.y 77 bison -d -y -t $< 78 79 main.c: $(VERSION) 80 81 %.o: %.c $(HEADERS) 82 $(CC) $(CFLAGS) -o $@ -c $<