#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements.  See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1  (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# *      http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# *      contact@openairinterface.org
# */

OUTDIR = .

libgtpv1u_OBJECTS = \
	nw-gtpv1u/src/NwGtpv1uTunnelEndPoint.o	\
	nw-gtpv1u/src/NwGtpv1uTrxn.o 	\
	nw-gtpv1u/src/NwGtpv1uMsg.o 	\
	nw-gtpv1u/src/NwGtpv1u.o 	\
	gtpv1u_eNB.o	\
	gtpv1u_teid_pool.o

# pull in dependency info for *existing* .o files
-include $(OUTDIR)/*.d

CFLAGS = \
	-Wall			\
	$(GTPV1U_CFLAGS)		\
	-DENB_MODE		\
	-Werror=uninitialized	\
	-Werror=implicit-function-declaration

$(OUTDIR)/%.o : %.c
	@echo "Compiling $<"
	@if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi;
	@$(CC) -c $(CFLAGS) -o $@ $<
	@$(CC) -MM $(CFLAGS) $< > $(basename $@).d
	@mv -f $(basename $@).d $(basename $@).d.tmp
	@sed -e 's|.*:|$@:|' < $(basename $@).d.tmp > $(basename $@).d
	@sed -e 's/.*://' -e 's/\\$$//' < $(basename $@).d.tmp | fmt -1 | \
	sed -e 's/^ *//' -e 's/$$/:/' >> $(basename $@).d
	@rm -f $(basename $@).d.tmp

objsdir:
	@if [ ! -d $(OUTDIR) ]; then mkdir -p $(OUTDIR); fi;

$(OUTDIR)/libgtpv1u.a: $(addprefix $(OUTDIR)/,$(libgtpv1u_OBJECTS))
	@echo Creating GTPV1U archive
	@$(AR) rcs $@ $(addprefix $(OUTDIR)/,$(libgtpv1u_OBJECTS))

clean:
	@$(RM_F_V) $(OUTDIR)/nw-gtpv1u/src/*.o
	@$(RM_F_V) $(OUTDIR)/nw-gtpv1u/src/*.d
	@$(RM_F_V) $(OUTDIR)/*.o
	@$(RM_F_V) $(OUTDIR)/*.d
	@$(RM_F_V) $(OUTDIR)/libgtpv1u.a

cleanall: clean
