1#
2# %CopyrightBegin%
3#
4# Copyright Ericsson AB 2002-2016. All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# %CopyrightEnd%
19#
20#
21include $(ERL_TOP)/make/target.mk
22include $(ERL_TOP)/make/$(TARGET)/otp.mk
23include $(ERL_TOP)/make/$(TARGET)/otp_ded.mk
24
25CC = $(DED_CC)
26LD = $(DED_LD)
27LIBS = $(DED_LIBS)
28
29# ----------------------------------------------------
30# Application version
31# ----------------------------------------------------
32include ../vsn.mk
33VSN=$(ASN1_VSN)
34
35# ----------------------------------------------------
36# Release directory specification
37# ----------------------------------------------------
38RELSYSDIR = $(RELEASE_PATH)/lib/asn1-$(VSN)
39
40
41# ----------------------------------------------------
42# FLAGS misc
43# ----------------------------------------------------
44ifeq ($(TYPE),debug)
45TYPEMARKER = .debug
46else
47TYPEMARKER =
48endif
49
50# ----------------------------------------------------
51# FLAGS
52# ----------------------------------------------------
53CFLAGS = $(DED_INCLUDES) $(EI_INCLUDES) $(DED_CFLAGS)
54STATIC_CFLAGS = $(DED_INCLUDES) $(EI_INCLUDES) $(DED_STATIC_CFLAGS)
55LDFLAGS += $(DED_LDFLAGS)
56
57# ----------------------------------------------------
58# Target Specs
59# ----------------------------------------------------
60
61NIF_OBJ_FILES = $(OBJDIR)/asn1_erl_nif.o
62NIF_STATIC_OBJ_FILES = $(OBJDIR)/asn1_erl_nif_static.o
63
64# Module and shared lib have to have same name of
65# static nifs to work
66ifeq ($(TARGET),win32)
67NIF_SHARED_OBJ_FILE = $(LIBDIR)/asn1rt_nif.dll
68NIF_LIB_FILE = $(LIBDIR)/asn1rt_nif.lib
69CLIB_FLAGS =
70LN=cp
71else
72NIF_SHARED_OBJ_FILE = $(LIBDIR)/asn1rt_nif.so
73NIF_LIB_FILE = $(LIBDIR)/asn1rt_nif.a
74CLIB_FLAGS = -lc
75LN= ln -s
76endif
77
78ifeq ($(USING_VC),yes)
79AR_OUT=-out:
80AR_FLAGS=
81else
82AR_OUT=
83ifeq ($(V),0)
84AR_FLAGS=rc
85else
86AR_FLAGS=rcv
87endif
88endif
89
90ifndef RANLIB
91RANLIB=true
92endif
93
94# ----------------------------------------------------
95# Targets
96# ----------------------------------------------------
97
98_create_dirs := $(shell mkdir -p $(OBJDIR) $(LIBDIR))
99
100opt: $(NIF_SHARED_OBJ_FILE)
101
102debug: opt
103
104static_lib: $(NIF_LIB_FILE)
105
106clean:
107	rm -f core *~
108	rm -f $(LIBDIR)/*
109	rm -f $(OBJDIR)/*
110
111docs:
112
113# ----------------------------------------------------
114# Special Build Targets
115# ----------------------------------------------------
116
117
118$(OBJDIR)/%.o: %.c
119	$(V_CC) -c $(CFLAGS) -O3 -o $@ $<
120
121$(OBJDIR)/%_static.o: %.c
122	$(V_CC) -c $(STATIC_CFLAGS) -O3 -o $@ $<
123
124$(NIF_LIB_FILE): $(NIF_STATIC_OBJ_FILES)
125	$(V_AR) $(AR_FLAGS) $(AR_OUT)$@ $(NIF_STATIC_OBJ_FILES)
126	$(V_RANLIB) $@
127
128$(NIF_SHARED_OBJ_FILE): $(NIF_OBJ_FILES)
129	$(V_LD) $(LDFLAGS) -o $(NIF_SHARED_OBJ_FILE) $(NIF_OBJ_FILES) $(CLIB_FLAGS) $(LIBS)
130
131# ----------------------------------------------------
132# Release Target
133# ----------------------------------------------------
134include $(ERL_TOP)/make/otp_release_targets.mk
135
136release_spec: opt
137	$(INSTALL_DIR) "$(RELSYSDIR)/priv/lib"
138	$(INSTALL_PROGRAM) $(NIF_SHARED_OBJ_FILE) "$(RELSYSDIR)/priv/lib"
139	$(INSTALL_DIR) "$(RELSYSDIR)/c_src"
140	$(INSTALL_DATA) *.c "$(RELSYSDIR)/c_src"
141
142release_docs_spec:
143
144