Makefile (3845B)
1 # 2 # This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 3 # 4 # Copyright 2007-2019 Broadcom Inc. All rights reserved. 5 # 6 # Makefile for CINT library 7 # 8 9 ifneq (,$(findstring cint,$(MAKECMDGOALS))) 10 LBUILD=1 11 endif 12 13 ifneq (,$(findstring utest,$(MAKECMDGOALS))) 14 LBUILD=1 15 endif 16 17 ifndef LBUILD 18 19 # Build as part of the SDK 20 LOCALDIR = src/appl/cint 21 include ${SDK}/make/Make.config 22 lib = libcint 23 include ${SDK}/make/Make.lib 24 include ${SDK}/make/Make.depend 25 26 else 27 28 # Build standalone interpreter application 29 30 CC := /tools/bin/gcc 31 PERL := perl 32 FLEX := /projects/ntsw-tools/bin/flex-2.5.31 33 YACC := /tools/bin/yacc 34 PATCH := patch 35 REPLACESTRING := /projects/ntsw-tools/bin/replacestring 36 YEAR := $(shell date +%Y) 37 TMP := tmp.h 38 39 SRCS := cint_ast.c 40 SRCS += cint_ast_debug.c 41 SRCS += cint_builtins.c 42 SRCS += cint_datatypes.c 43 SRCS += cint_debug.c 44 SRCS += cint_error.c 45 SRCS += cint_eval_ast_cint.c 46 SRCS += cint_eval_ast_print.c 47 SRCS += cint_eval_asts.c 48 SRCS += cint_internal.c 49 SRCS += cint_interpreter.c 50 SRCS += cint_operators.c 51 SRCS += cint_parser.c 52 SRCS += cint_test_data.c 53 SRCS += cint_variables.c 54 SRCS += main.c 55 SRCS += cint_stubs.c 56 # generated 57 SRCS += cint_c.lex.c 58 SRCS += cint_c.tab.c 59 60 CFLAGS := -g -O0 61 62 # portability interfaces - pick one 63 CFLAGS += -DCINT_CONFIG_INCLUDE_STDLIB=1 64 CFLAGS += -DCINT_CONFIG_INCLUDE_SDK_SAL=0 65 CFLAGS += -DCINT_CONFIG_INCLUDE_STUBS=0 66 67 # test features 68 CFLAGS += -DCINT_CONFIG_INCLUDE_LOAD=1 69 CFLAGS += -DCINT_CONFIG_INCLUDE_MAIN=1 70 CFLAGS += -DCINT_CONFIG_INCLUDE_TEST_DATA=1 71 72 # FILE IO and READLINE 73 #CFLAGS += -DCINT_CONFIG_FILE_IO=0 74 #CFLAGS += -DCINT_CONFIG_INCLUDE_XINCLUDE=0 75 #CFLAGS += -DCINT_CONFIG_INCLUDE_PARSER_READLINE=0 76 #CFLAGS += -DCINT_CONFIG_INCLUDE_PARSER_ADD_HISTORY=0 77 78 # other configs 79 #CFLAGS += -DCINT_CONFIG_INCLUDE_PARSER=0 80 #CFLAGS += -DCINT_CONFIG_INCLUDE_DOUBLES=0 81 #CFLAGS += -DCINT_CONFIG_INCLUDE_LONGLONGS=0 82 #CFLAGS += -DCINT_CONFIG_INCLUDE_CINT_LOAD=0 83 #CFLAGS += -DCINT_CONFIG_INCLUDE_DTRACE=0 84 #CFLAGS += -DCINT_CONFIG_INCLUDE_DEBUG=0 85 #CFLAGS += -DCINT_CONFIG_INCLUDE_POSIX_TIMER=0 86 #CFLAGS += -DCINT_CONFIG_YAPI=1 87 88 # unused configs 89 #CFLAGS += -DCINT_CONFIG_PARSER_STDIN=0 90 #CFLAGS += -DCINT_CONFIG_INCLUDE_CINT_SOURCE=1 91 92 CFLAGS += -Wall 93 CFLAGS += -Werror 94 CFLAGS += -DYYDEBUG 95 96 OBJS := $(SRCS:%.c=%.o) 97 98 DEPS := $(SRCS:%.c=%.d) 99 100 all: cint 101 102 gen: cint_c.lex.c cint_c.tab.c cint_wrappers.h 103 104 cint: $(OBJS) 105 $(CC) -o $@ $+ -ldl -lrt -lreadline -lcurses 106 107 cint_c.tab.c: cint_grammar.y 108 $(YACC) -dv -o $@ $< 109 # Avoid compiler warnings 110 $(REPLACESTRING) -a "YYSTYPE yylval;" "YYSTYPE yylval = 0;" $@ 111 $(REPLACESTRING) -a "YYLTYPE yylloc;" "YYLTYPE yylloc = {0,0,0,0};" $@ 112 # use CINT bindings via BISON interfaces 113 $(REPLACESTRING) -a "yyps = (yypstate *) malloc (sizeof *yyps)" \ 114 "yyps = (yypstate *) YYMALLOC (sizeof *yyps)" $@ 115 $(REPLACESTRING) -a "free (yyps)" "YYFREE (yyps)" $@ 116 # use standard BRCM id/copyright 117 @echo '/* ' > $(TMP) 118 @echo -n ' $$' >> $(TMP) 119 @echo -n 'Id: ' >> $(TMP) 120 @echo '$$' >> $(TMP) 121 @echo ' $$Copyright: $(YEAR) Broadcom Corp.' >> $(TMP) 122 @echo ' All Rights Reserved.$$' >> $(TMP) 123 @echo '*/' >> $(TMP) 124 @cat cint_c.tab.h >> $(TMP) 125 @rm cint_c.tab.h 126 @mv tmp.h cint_c.tab.h 127 128 cint_c.lex.c: cint_scanner.l lex.patch 129 $(FLEX) --nounistd -o $@ $< 130 $(PATCH) < lex.patch 131 132 cint_wrappers.h: wrappergen.pl 133 $(PERL) $< > $@ 134 135 utest: cint utest-a.h utest-b.h 136 rm -f *.code *.actual *.expected 137 $(PERL) utest.pl utests 138 139 utest-a.h: 140 echo "print 1;" > $@ 141 142 utest-b.h: 143 echo "#include <utest-a.h>" > $@ 144 echo "print 121;" >> $@ 145 echo "#include <utest-a.h>" >> $@ 146 147 148 clean: 149 -rm -f cint $(OBJS) $(DEPS) cint_wrappers.h cint_c.*.[ch] utest-*.h 150 151 ifneq ($(MAKECMDGOALS),clean) 152 include $(DEPS) 153 endif 154 155 # calculate C include dependencies 156 %.d: %.c 157 @$(SHELL) -ec "$(CC) -M -MG $(CFLAGS) $< > $@; [ -s $@ ] || rm -f $@" 158 159 endif 160 161 162