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