1#
2# configure.in - input script to autoconf to
3#                configure directory
4#
5# This file is part of the GNU PIC Library.
6#
7# Originally written by
8# 	Vangelis Rokas <vrokas@otenet.gr>
9#
10# Adopted for the SDCC/pic14 library by
11#	Raphael Neider <rneider AT web.de>
12#
13# Added libc and DEBUG/NOOPTS/EXPERIMENTAL conditionals by
14#       Gonzalo Pérez de Olaguer Córdoba <salo@gpoc.es>
15#
16# $Id: configure.ac 11276 2019-06-12 20:56:32Z spth $
17#
18
19# Process this file with autoconf to produce a configure script.
20AC_PREREQ(2.60)
21AC_INIT([pic14lib], [0.1], [tecodev AT users sourceforge net])
22AM_INIT_AUTOMAKE([foreign subdir-objects no-dependencies])
23AC_CONFIG_SRCDIR([libsdcc/idata.c])
24AC_CONFIG_HEADER([config.h])
25
26# SDCC setup
27case $srcdir in
28    [\\/]*|?:[\\/]*) abs_srcdir="$srcdir";
29        ;;
30    *) abs_srcdir="$ac_pwd/$srcdir";
31        ;;
32esac
33case $ac_top_build_prefix in
34    [\\/]*|?:[\\/]*)
35        abs_top_builddir="$ac_top_build_prefix";
36        ;;
37    *) abs_top_builddir="$ac_pwd/$ac_top_build_prefix";
38        ;;
39esac
40
41libdir=$libdir/pic14
42
43# Checks for programs.
44# The default architectures (regular and enhanced cores) can be selected at
45# configure time by setting the environment variables PICARCH and/or EARCH to
46# the desired device (16fxxx).
47AC_SUBST(PICARCH,  [${PICARCH:-16f877}])
48# Previous default setting for EARCH was 16f1934, but gpsim doesn't support it.
49# It should be used the device with larger ROM and RAM sizes.
50AC_SUBST(EARCH, [${EARCH:-16f1788}])
51
52# We cannot use AC_PROG_CC(sdcc) as sdcc might not be built at configure-time...
53AC_SUBST(CC, [\'$abs_top_builddir/../../../bin/sdcc\'])
54AC_PATH_PROG(CCAS, gpasm, :)
55AC_PATH_PROG(LD, gplink, :)
56AC_PATH_PROG(AR, gplib, :)
57
58case ":$CCAS:$LD:$AR:" in
59    *:::*)
60        AC_MSG_ERROR([gputils (gpasm, gplink, and gplib) are required but not found.
61Either install gputils or reconfigure with --disable-pic14-port and --disable-pic16-port.])
62        ;;
63esac;
64
65mCCAS="$CCAS"
66mLD="$LD"
67AC_SUBST(CFLAGS, [""])
68AC_SUBST(CCASFLAGS, [""])
69AC_SUBST(LDFLAGS, ["-m -l -w"])
70AC_SUBST(ARFLAGS, ["-c"])
71AC_SUBST(CCAS, [\'$CCAS\'])
72AC_SUBST(LD, [\'$LD\'])
73AC_SUBST(AR, [\'$AR\'])
74
75# $RANLIB is called by the autotools but not provided nor required
76AC_SUBST(RANLIB, [:])
77AC_SUBST(OBJEXT, [o])
78
79_AM_DEPENDENCIES(CC)
80_AM_DEPENDENCIES(CCAS)
81
82AC_MSG_CHECKING([whether gputils support enhanced cores])
83# Check support for enhanced pic cores.
84ENABLE_ENHANCED_PICS="no"
85CHECK=".checkdevices/check"
86mkdir -p .checkdevices
87printf '  include "p%s.inc"\n  END\n' "${EARCH}" > "${CHECK}.asm"
88if "$mCCAS" -p${EARCH} -o "${CHECK}.o" -c "${CHECK}.asm" >/dev/null 2>&1 && "$mLD" "${CHECK}.o" >/dev/null 2>&1; then
89  ENABLE_ENHANCED_PICS="yes"
90fi;
91AC_MSG_RESULT([$ENABLE_ENHANCED_PICS])
92AM_CONDITIONAL([ENABLE_ENHANCED_PICS], [ test x$ENABLE_ENHANCED_PICS = xyes ])
93
94AC_MSG_CHECKING([wheter gputils support the extended instruction set])
95ENABLE_EXTENDED_INSTRUCTIONS="no"
96printf '  include "p%s.inc"\n  CODE\n  ADDFSR FSR0, 4\n  MOVIW FSR0++\n  END\n' "${EARCH}" > "${CHECK}.asm"
97if "$mCCAS" -p${EARCH} -o "${CHECK}.o" -c "${CHECK}.asm" >/dev/null 2>&1 && "$mLD" "${CHECK}.o" >/dev/null 2>&1; then
98  ENABLE_EXTENDED_INSTRUCTIONS="yes"
99fi;
100AC_MSG_RESULT([$ENABLE_EXTENDED_INSTRUCTIONS])
101AM_CONDITIONAL([ENABLE_EXTENDED_INSTRUCTIONS], [ test x$ENABLE_EXTENDED_INSTRUCTIONS = xyes ])
102
103# default values for the following conditions
104: ${DEBUG:=0}
105: ${NOOPTS:=0}
106: ${EXPERIMENTAL:=0}
107
108# generate debug info during the build process
109AM_CONDITIONAL([ENABLE_DEBUG], [ test x$DEBUG = x1 ])
110
111# build libraries with optimizations disabled
112AM_CONDITIONAL([ENABLE_NOOPTS], [ test x$NOOPTS = x1 ])
113
114# build libraries with experimental code enabled
115AM_CONDITIONAL([ENABLE_EXPERIMENTAL], [ test x$EXPERIMENTAL = x1 ])
116
117# Checks for libraries.
118
119# Checks for header files.
120
121# Checks for typedefs, structures, and compiler characteristics.
122
123# Checks for library functions.
124
125AC_CONFIG_FILES([Makefile
126                 libsdcc/enhanced/Makefile
127                 libsdcc/enhanced-no-xinst/Makefile
128                 libsdcc/regular/Makefile
129                 libc/Makefile
130                 libm/Makefile])
131AC_OUTPUT
132